<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    @Author 硕鼠
    @Date 2020/4/7 10:52
    @Version 1.0
    @Description 数组排序
  -->
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        // var arr = ['float','width','alpha','left']; //字符串排序
        // arr.sort();
        // alert(arr);

        var arr = [112,17,9,4,8]; //数字排序,数字当成字符串排序
        arr.sort(function (n1,n2) {//sort只认识字符串
            return n1 - n2;
            // if(n1 < n2){
            //     return -1;
            // }else if(n1 > n2){
            //     return 1;
            // }else {
            //     return 0;
            // }
        });
        alert(arr);
    </script>
</head>
<body>

</body>
</html>